<template>
	<view class="item" @tap="itemClick">
		<view class="img center">
			<image :src="goods.main_image" class="auto-img img-radius"></image>
			<view class="time-count-position">
				<template v-if="itemType==0">
					<uni-countdown :show-day="true" :day="timeOne.day" color="#fff" splitorColor='#fff'
						:hour="timeOne.hour" :minute="timeOne.minute" :second="timeOne.second" :fontSize='10'
						ref="countDownRef" @timeup='countEnd'></uni-countdown>
				</template>
				
				<template v-if="itemType==1">
					<uni-countdown :show-day="true" :day="timeTwo.day" color="#fff" splitorColor='#fff'
						:hour="timeTwo.hour" :minute="timeTwo.minute" :second="timeTwo.second" :fontSize='10'
						ref="countDownRef" @timeup='countTwoEnd'></uni-countdown>
				</template>
				<view style="font-size: 20rpx;color: #fff;padding: 6rpx 12rpx;" v-if="itemType==2">
					已结束
				</view>
			</view>
		</view>
		<view class="name">
			{{goods.title}}
		</view>
		<view class="price">
			<span>￥</span>
			<view class="money line-money">{{goods.line_price}}</view>
			<view class="money">{{goods.seckill_price/100}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			goods: {
				type: Object,
				default: {}
			},
			beginTime: {
				type: String,
				default: '',
			},
			endTime: {
				type: String,
				default: '',
			},
			itemType: {
				type: Number,
				default: 0,
			}
		},
		computed: {
			timeOne() {
				let str=this.$tools.getUnixToDate('yyyy-mm-dd',this.endTime)
				let strTwo=str.replace(/-/g, "/")
				let times=this.$tools.getDHS(strTwo)
				return times
			},
			timeTwo() {
				 let str=this.$tools.getUnixToDate('yyyy-mm-dd',this.endTime)
				 let strTwo=str.replace(/-/g, "/")
				 let times=this.$tools.getDHS(strTwo)
				 return times
			}
		},
		data() {
			return {
				 
			}
		},
		methods: {
			itemClick() {
				this.$emit('itemClick', this.goods.id)
			},
			countEnd() {
				//正在抢购倒计时结束
				this.$emit('countEnd')
			},
			countTwoEnd() {
				//正在抢购倒计时结束
				this.$emit('countEndTwo')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.item {
		margin-left: 22rpx;
		width: 206rpx;
		margin-bottom: 40rpx;

		.img {
			width: 206rpx;
			height: 206rpx;
			border-radius: 8rpx;
			position: relative;

			.time-count-position {
				position: absolute;
				left: 0;
				top: 0;
			 
				border-radius: 8rpx;
				background: rgba(203, 60, 40, 1);
			}
		}

		.name {
			margin-top: 16rpx;
			font-size: 24rpx;
			font-weight: 400;
			color: rgba(0, 0, 0, 0.9);
			text-overflow: -o-ellipsis-lastline;
			overflow: hidden; //溢出内容隐藏
			text-overflow: ellipsis; //文本溢出部分用省略号表示
			display: -webkit-box; //特别显示模式
			-webkit-line-clamp: 2; //行数
			line-clamp: 2;
			-webkit-box-orient: vertical; //盒子中内容竖直排列

		}

		.price {
			margin-top: 16rpx;
			display: flex;
			align-items: center;
			color: rgba(189, 149, 91, 1);

			span {
				font-size: 20rpx;
			}

			.money {
				font-size: 28rpx;
			}

			.line-money {
				margin-right: 20rpx;
				text-decoration: line-through;
			}

		}
	}
</style>
